import os
import time
import random


#主线本
s3_1=82
n2_4=90
n3_2=108
n2_10=101
#######

#资源本
ca3=95
sk4=88
ls4=82
ce4=101
ce5=118
prb1=95
prb2=135
#######

#常驻本
gt5=100
#######

#活动本
pl3=128
tw7=125
#######

text= ""

with open(text,"r",encoding="utf-8") as m:
    data=m.read()
print(data)

#本次运行副本
now=int(input("本时间（默认 125）：") or tw7)
############

#本次循环次数
r=int(input("输入刷本次数(默认 1）：")or 1)
############


#检测连接及自动连接
os.system('adb kill-server')
op = os.popen('adb devices')
s = op.read()

ip = ""

ans="List of devices attached\n"+ip+"	device"
result = ans in s
if result == True:
    print("already connected")
else:
    print("connecting...")
    os.system('adb connect '+ip+'')
###################

i=1
a=random.randint(2,3)
b=random.randint(now,now+5)
c=random.randint(3,5)
ref_time=a
proc_time=b
net_ref=c
while i <= r:
    process=os.system('adb shell input tap 2225 995');
    print("ready")
    time.sleep(ref_time)
    process=os.system('adb shell input tap 1950 800');
    time.sleep(net_ref)
    print("start")
    time.sleep(proc_time)
    process=os.system('adb shell input tap 2225 995');
    time.sleep(net_ref)
    print("done",i)
    i+=1
print("finish")